<%@ page language="java" import="java.util.*" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/context/mytags.jsp"%>
<!DOCTYPE html>
<html>
 <head>
  <title>工序汇报</title>
  <t:base type="jquery,easyui,tools,DatePicker,utils,yongxin_js,yongxin_css,mobile_css"></t:base>
 </head>
 <script>
    	$(document).ready(function(){
        $("#fworkshop").val('1002');
      
    });
 
 
 	$(function(){
 	
 			$.ajax({
				type : "POST",
				url : "processReportController.do?getProcess&fbcph=${processReportPage.fbcph}",
				data: {},
				success : function(jsondata) {
						data = $.parseJSON(jsondata);
						var str ="";
						$(data.obj).each(function(i,j){
							//console.log(j);
							
							str +="<span class='progress'>"+j.typename+"("+j.fbcph+")</span>";
							if(i%6==0){
								str +="<br><br>";
							}
							str +="<span >-----></span>";
							
							//console.log(str);
							
						});
						//str +=data.msg;
						
						console.log(str);
						$('#div_process').html(str);
						$('#div_nprocess').html(data.msg);
						$('#t_div_nprocess').html(data.msg);
						$('#nprocess').val('${processReportPage.nprocess}');
					}
			});
			
			var char=['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'];
			var num = 0;
			var lastCommunAddTr = $("#record_tr");

		   $("#add_btn").click(function() {//复制一行
		        
		        document.getElementById('ftrzl').readOnly = false;
		        
		   		if($(".trRecord").length==1){
		   			$("#record_tr").find("#fbcph").get(0).value +="-"+char[num];
		   			num++;
		   		}
		   		
		   		
               var tr = $("#temp_tr").clone(true);
               tr.attr('id',tr.attr('id')+char[num]);
          		
          		tr.attr('class','trRecord');
           		
           		
           		tr.find("#fbcph").get(0).value +="-"+char[num];
           		
               tr.insertAfter(lastCommunAddTr);
               lastCommunAddTr = tr;
               num++;
              
            });
            
            $("#del_btn").click(function() {//复制一行
              var delIndexs = new Array(0);
              $(".trRecord:gt(0)").each(function(i) {
              		
					if($(this).find("#ck").get(0).checked == true){
                  		delIndexs.splice(delIndexs.length,0,i);
                     	$(this).remove();
                    }
					 
                });
                
                
                 $(".trRecord").each(function(i) {
                	
                	if($(".trRecord").length==1){
                	   document.getElementById('ftrzl').readOnly = true;
                       $('#ftrzl').val('${processReportPage.ftrzl}');
			   			$("#record_tr").find("#fbcph").get(0).value ="${processReportPage.fbcph}";
			   			num=0;
			   			
			   		}
			   		else{
			   			$(this).find("#fbcph").get(0).value ="${processReportPage.fbcph}-"+char[i];
			   		}
                	
                
                 	lastCommunAddTr = $(this);
                 
                });
                
              
            });
            
            $("#save_btn").click(function() {//复制一行
               top.$(".ui_state_highlight").hide();
                //保存之前判断分卷重量是否合理
	         if(!checkFJ()){
	          return false;
	         }
	         
	          /*保存之前判断产出重量是否大于投入重量*/
             if(!checkCC()){
	          return false;
	         }
              	ajaxdoForm('processReportController.do?save&fstate=1','formobj');
				$("#save_btn").hide();
				$("#add_btn").hide();
				$("#del_btn").hide();
            });
         selChange();   
 	});
 
 	   function selChange(){

  var sel = $("#fworkshop").val();
  $.ajax({
		type : "POST",
		url : "processReportController.do?getMatchinegroupList&process=${processReportPage.cprocess}",
		data: {pid:$('#fworkshop').val()},
		success : function(jsondata) {
				data = $.parseJSON(jsondata);
				console.log(data);
				$('#fmatchinegroup').html(data.msg);
			  	$('#fmatchinegroup').val("${processReportPage.fmatchinegroup}");
			}
	});
	
}

 </script>
  <body>
	<div id="wrapper">
				<t:formvalid formid="formobj" dialog="true" usePlugin="password" layout="table" tiptype="1"
					action="processReportController.do?save&fstate=2" beforeSubmit="checkNprocessEmpty">
					<input id="id" name="id" type="hidden" value="${processReportPage.id }">
					<input type="hidden" id="cprocess" name="cprocess" class="mytxt" ignore="ignore" value="${processReportPage.cprocess}">
					<input type="hidden" id="trzl" name="trzl" value="${processReportPage.ftrzl}">
					<table cellpadding="0" cellspacing="1" class="formtable">
						<tr>
							<td align="center" colspan=16>
								<label class="Validform_label">
									连续退火炉工序汇报单
								</label>
							</td>

						</tr>
						<tr>
							<td align="center" colspan=16 style="background-color: white; padding: 20px">
								<div id="div_process"></div>

							</td>

						</tr>
						<tr style="display: none">
							<td align="center">
								<label class="Validform_label">
									制单时间
								</label>
							</td>
							<td class="value" colspan=15>
								<input class="mytxt" style="width: 140px" id="updateDate" name="updateDate" class="mytxt" ignore="ignore"
									value="<fmt:formatDate value='${processReportPage.updateDate}' type="date" pattern="yyyy-MM-dd HH:mm:ss"/>" ReadOnly>
								<!--
						<input class="Wdate" onClick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})"  style="width: 150px" id="createDate" name="createDate" class="mytxt"  ignore="ignore"
							   >
					-->
							</td>
						</tr>
						<tr>
							<td align="center">
								<label class="Validform_label">
									生产车间
								</label>
							</td>
							<td class="value" colspan=15>
								<!--<t:dictSelect field="fworkshop" typeGroupCode="workshop" hasLabel="false"  defaultVal="${processReportPage.fworkshop}" extendJson="{id:sel2}"></t:dictSelect>
							-->
							  <select  id="fworkshop"  name="fworkshop" onchange="selChange()">
								     <c:forEach items="${workshopList}" var="workshop">
								        <option value="${workshop.id}"   <c:if test="${workshop.id==processReportPage.fworkshop}"> selected="selected"</c:if>>${workshop.name}</option>
								     </c:forEach>
								</select>
							</td>
						</tr>
						<tr>
							<td align="center">
								<label class="Validform_label">
									班组
								</label>
							</td>
							<td class="value" colspan=15>
								<t:dictSelect field="fworkgroup" typeGroupCode="team" hasLabel="false"  defaultVal="${processReportPage.fworkgroup}" extendJson="{id:sel2}"></t:dictSelect>
							</td>
						</tr>


						<tr>
							<td align="center">
								<label class="Validform_label">
									机组
								</label>
							</td>
							<td class="value" colspan=15>
								<!--<input id="fmatchinegroup" name="fmatchinegroup" style="width: 140px" class="mytxt" ignore="ignore"
									value="${processReportPage.fmatchinegroup}">

							-->
							<select id='fmatchinegroup' name='fmatchinegroup'><option value=''>请选择</option></select>
							</td>
						</tr>
							<tr>
							   <td align="center">
							   <label class="Validform_label">
										开工时间
							   </label>
							   </td>
							   	<td class="value" colspan=15>
									<input class="mytxt" onClick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" id="startDate" name="startDate" ignore="ignore" style="width: 140px;"
										value="<fmt:formatDate value='${processReportPage.startDate}' type="date" pattern="yyyy-MM-dd HH:mm:ss"/>" >
								</td>
							</tr>
						<tr style="display: none">
							<td align="center">
								<label class="Validform_label">
									制单人
								</label>
							</td>
							<td class="value" colspan=15>
								<input id="createBy" name="createBy" style="width: 140px" class="mytxt" ignore="ignore" readOnly
									value="${processReportPage.createBy}">

							</td>
						</tr>
						<tr>
							<td align="center" rowspan="2">
								<label class="Validform_label">
									本厂批号
								</label>
							</td>
							<td align="center" rowspan="2">
								<label class="Validform_label">
									投入厚度
								</label>
							</td>
							<td align="center" rowspan="2">
								<label class="Validform_label">
									投入宽度
								</label>
							</td>
							<td align="center" rowspan="2">
								<label class="Validform_label">
									投入重量
								</label>
							</td>
							<td align="center" rowspan="2">
								<label class="Validform_label">
									产出厚度
								</label>
							</td>
							<td align="center" rowspan="2">
								<label class="Validform_label">
									产出宽度
								</label>
							</td>
							<td align="center" rowspan="2">
								<label class="Validform_label">
									产出重量
								</label>
							</td>
							<td align="center" rowspan="2">
								<label class="Validform_label">
									报废重量
								</label>
							</td>
							<td align="center" rowspan="2">
								<label class="Validform_label">
									成材率
								</label>
							</td>
							<td align="center" colspan="5">
								<label class="Validform_label">
									退火工艺
								</label>
							</td>
							<td align="center" rowspan="2">
								<label class="Validform_label">
									质量情况
								</label>
							</td>
							<td align="center" rowspan="2">
								<label class="Validform_label">
									下一工序
								</label>
							</td>
						</tr>

						<tr>
							<td align="center" colspan="3">
								<label class="Validform_label">
									退火温度
								</label>
							</td>
							<td align="center">
								<label class="Validform_label">
									炉内张力
								</label>
							</td>
							<td align="center">
								<label class="Validform_label">
									速度
								</label>
							</td>
						</tr>
						<tr id="record_tr" class="trRecord">
							<td class="value" style="text-align: right">

								<input id="fbcph" name="fbcph" class="mytxt" ignore="ignore" value="${processReportPage.fbcph}" style="width: 120px"
									ReadOnly>
                                <input type="hidden"  name="fwlname" value="${processReportPage.fwlname}">
							</td>
							<td class="value">

								<input id="ftrhd" name="ftrhd" class="mytxt" ignore="ignore" value="${processReportPage.ftrhd}">
							</td>
							<td class="value">
								<input id="ftrkd" name="ftrkd" class="mytxt" ignore="ignore" value="${processReportPage.ftrkd}">

							</td>
							<td class="value">
								<input id="ftrzl" name="ftrzl" class="mytxt"  ReadOnly  ignore="ignore" value="${processReportPage.ftrzl}">

							</td>
							<td class="value">

								<input id="fcchd" name="fcchd" class="mytxt" ignore="ignore" dataType="d" value="${processReportPage.fcchd}">
							</td>
							<td class="value">
								<input id="fcckd" name="fcckd" class="mytxt" ignore="ignore" dataType="d" value="${processReportPage.fcckd}">

							</td>
							<td class="value">
								<input id="fcczl" name="fcczl" class="mytxt" ignore="ignore" dataType="d" value="${processReportPage.fcczl}">

							</td>
							<td class="value">
								<input id="fbfzl" name="fbfzl" class="mytxt" ignore="ignore" value="${processReportPage.fbfzl}" ReadOnly>

							</td>
							<td class="value">
								<input id="frate" name="frate" class="mytxt" ignore="ignore" value="${processReportPage.frate}" ReadOnly>

							</td>
							<td class="value">
								<input id="fthwd1" name="fthwd1" class="mytxt" ignore="ignore" dataType="d" value="${processReportPage.fthwd1}">
							</td>
							<td class="value">
								<input id="fthwd2" name="fthwd2" class="mytxt" ignore="ignore" dataType="d" value="${processReportPage.fthwd2}">
							</td>
							<td class="value">
								<input id="fthwd3" name="fthwd3" class="mytxt" ignore="ignore" dataType="d" value="${processReportPage.fthwd3}">
							</td>
							<td class="value">
								<input id="flnzl" name="flnzl" class="mytxt" ignore="ignore" dataType="d" value="${processReportPage.flnzl}">

							</td>
							<td class="value">
								<input id="fsd" name="fsd" class="mytxt" ignore="ignore" dataType="d" value="${processReportPage.fsd}">

							</td>
							<td class="value">
								<input id="fnote" name="fnote" class="mytxt" ignore="ignore" value="${processReportPage.fnote}">

							</td>
							<td class="value">
								<div id="div_nprocess" class="div_nprocess"></div>
							</td>
						</tr>



					</table>
				</t:formvalid>
				<div id="dlg-buttons">
					<table cellpadding="0" cellspacing="0" style="width: 100%">
						<tr>

							<td style="padding-top: 10px">
								<a href="#" class="easyui-linkbutton btn" iconCls="icon-save" id="save_btn">保存</a>
								<a href="#" class="easyui-linkbutton btn" iconCls="icon-add" id="add_btn">增加批号</a>
								<a href="#" class="easyui-linkbutton btn" iconCls="icon-remove" id="del_btn">删除批号</a>
							</td>
						</tr>
					</table>
				</div>



				<table style="width: 600px; display: none" cellpadding="0" cellspacing="1">

					<tr id="temp_tr">
						<td class="value" nowrap >
							<input type="checkbox" id="ck">
							<input id="fbcph" name="fbcph" class="mytxt" ignore="ignore" style="width: 120px" value="${processReportPage.fbcph}"
								ReadOnly>

						</td>
						<td class="value">

							<input id="ftrhd" name="ftrhd" class="mytxt" ignore="ignore" value="${processReportPage.ftrhd}">
						</td>
						<td class="value">
							<input id="ftrkd" name="ftrkd" class="mytxt" ignore="ignore" value="${processReportPage.ftrkd}">

						</td>
						<td class="value">
							<input id="ftrzl" name="ftrzl" class="mytxt" ignore="ignore" value="${processReportPage.ftrzl}">

						</td>
						<td class="value">

							<input id="fcchd" name="fcchd" class="mytxt" ignore="ignore" dataType="d">
						</td>
						<td class="value">
							<input id="fcckd" name="fcckd" class="mytxt" ignore="ignore" dataType="d">

						</td>
						<td class="value">
							<input id="fcczl" name="fcczl" class="mytxt" ignore="ignore" dataType="d">

						</td>
						<td class="value">
							<input id="fbfzl" name="fbfzl" class="mytxt" ignore="ignore" ReadOnly>

						</td>
						<td class="value">
							<input id="frate" name="frate" class="mytxt" ignore="ignore" ReadOnly>
						</td>
						<td class="value">
							<input id="fthwd1" name="fthwd1" class="mytxt" ignore="ignore" dataType="d">
						</td>
						<td class="value">
							<input id="fthwd2" name="fthwd2" class="mytxt" ignore="ignore" dataType="d">
						</td>
						<td class="value">
							<input id="fthwd3" name="fthwd3" class="mytxt" ignore="ignore" dataType="d">
						</td>
						<td class="value">
							<input id="flnzl" name="flnzl" class="mytxt" ignore="ignore" dataType="d">
						</td>
						<td class="value">
							<input id="fsd" name="fsd" class="mytxt" ignore="ignore" dataType="d">
						</td>
						<td class="value">
							<input name="fnote" class="mytxt" ignore="ignore">

						</td>
						<td class="value">
							<div id="t_div_nprocess" class="div_nprocess"></div>
						</td>
					</tr>
				</table>
		</div>
	</body>	
